#!/bin/bash

time=`date +"%T"`
date=`date`
file="iostat.ouput.$time.txt"
echo "$date" > "$file"
iostat -x 1  >> "$file" &

echo "Press CTRL-D to exit"
cat

trap "kill 0" SIGINT SIGTERM EXIT

time=`date +"%T"`
echo "$date" >> "$file"
echo "Exiting" >> "$file"

exit